/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!
  \file			flt_words.h
  \date			Aug 2011
  \author		TNick

  \brief		Contains the definition for Flt_Words class


 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @n
 Please read ReadMe.txt and Licence.txt in root folder @n
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @n

*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
#ifndef __FLT_WORDS_INC__
#define __FLT_WORDS_INC__
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */

#include    <QRegExp>

#include    <filters/abstractfilter.h>

/*  INCLUDES    ============================================================ */
//
//
//
//
/*  CLASS    --------------------------------------------------------------- */

/// class
/**
*
*/
class Flt_Words : public AbstractFilter		{

	//
	//
	//
	//
	/*  DEFINITIONS    ----------------------------------------------------- */

	enum    FLG        {
		NO_FLAGS = 0,

		FILTER_ENABLED = 0x0001,

		NAME_ENABLED = 0x0002,
		CONT_ENABLED = 0x0004,

		MAX_FLAGS
	};


	/*  DEFINITIONS    ===================================================== */
	//
	//
	//
	//
	/*  DATA    ------------------------------------------------------------ */

private:

	/** @name AbstractFilter */
	//@{

	/// the unique instance
	static Flt_Words *       uniq_instance;

	//@}


	FLG        flags;

    /// cache list of words for name here
    QStringList                 lst_name;

	/// cache list of words for content here
    QStringList                 lst_cont;

	/*  DATA    ============================================================ */
	//
	//
	//
	//
	/*  FUNCTIONS    ------------------------------------------------------- */


private:
	/// constructor; to enshure unique instance, this is private (guidance)
	Flt_Words		(void);

	/// destructor;
	virtual				~Flt_Words		(void);



public:

	/** @name AbstractFilter */
	//@{

	/// function used to create the instance of the filter or return existing
	/**
 *	a single instance is required. As such, we store the pointer on first
 *  call and, on subsequent call, we simple return that pointer.
 *
 *	@return		new / existing instance as pointer
 */
	static Flt_Words*	initFilter		(void);


	/// tell the name of this filter
	virtual QString     name                (void);

	/// tell if this filter is enabled
	virtual bool        active              (void);


	/// function that populates a tab with it's options
	/**
	  * returned pointer of type void* is used in subsequent opperations
	  */
	virtual void*       createOptions       (QWidget* parent);


	/// function informed that the user pressed OK in options
	/**
	  * The implementation is required to save the settings choosen in
	  * the options page. @n
	  * The function is connected with accepted() signal in FiltOpts class.
	  * Each of the registered filters (see registerFilter()) are iterated
	  * and asked to save the data in the gui.
	  */
	virtual void        saveOptions         (
		QWidget *   parent,     /**< parent widget */
		bool        active_sts, /**< tells wether the user enabled or disabled
									  the use of this filter */
		void *      data        /**< associated data returned by the
								createOptions() function */
		);


	/// filter a page (tell if it's on the chain or off the chain)
	virtual bool        passesFilter        (PageData * pg_data);

	/// filter a page (tell if it's on the chain or off the chain)
	void                guiAsksToSave       (void);

	//@}



	/// set if the filter is active or not
	inline void     setFiltActive          (bool b_set)
	{
		if (b_set) flags = (FLG)(flags | FILTER_ENABLED);
		else flags = (FLG)(flags & (~FILTER_ENABLED));
	}
	/// is filter checked?
	inline bool     filtActive             (void)
	{ return ((flags & FILTER_ENABLED) != 0); }


	/// set content check
	inline void     setContEnabled          (bool b_set)
	{
		if (b_set) flags = (FLG)(flags | CONT_ENABLED);
		else flags = (FLG)(flags & (~CONT_ENABLED));
	}
	/// is content checked?
	inline bool     contEnabled             (void)
	{ return ((flags & CONT_ENABLED) != 0); }

	/// set name check
	inline void     setNameEnabled          (bool b_set)
	{
		if (b_set) flags = (FLG)(flags | NAME_ENABLED);
		else flags = (FLG)(flags & (~NAME_ENABLED));
	}
	/// is name checked?
	inline bool     nameEnabled             (void)
	{ return ((flags & NAME_ENABLED) != 0); }




	/*  FUNCTIONS    ======================================================= */
	//
	//
	//
	//

};	/*	class Flt_Words	*/

/*  CLASS    =============================================================== */
//
//
//
//
#endif // __FLT_WORDS_INC__
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
